import CategoryService from '../../api/category'

Page({
  data: {
    categoryList: [],
    activeIndex: 0
  },
  async getCategoryData() {
    const res = await CategoryService.getCategoryData()
    this.setData({
      categoryList: res.data
    })
    console.log(this.data.categoryList)
  },
  // 一级分类的切换效果
  updateActive(e) {
    const { currentTarget: { dataset: { index } } } = e
    this.setData({
      activeIndex: index
    })
  },
  onLoad() {
    this.getCategoryData()
  }
})
